package com.ruoyi.wechat.service.impl;

import com.ruoyi.common.utils.uuid.IdUtils;

import com.ruoyi.wechat.domain.CampFacility;
import com.ruoyi.wechat.domain.WxCampFacility;
import com.ruoyi.wechat.mapper.WxCampFacilityMapper;
import com.ruoyi.wechat.service.IWxCampFacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class WxCampFacilityServiceImpl implements IWxCampFacilityService {
    @Autowired
    private WxCampFacilityMapper campFacilityMapper;

    /**
     * 查询营地服务设施记录表
     *
     * @param cfId 营地服务设施记录表主键
     * @return 营地服务设施记录表
     */
    @Override
    public WxCampFacility selectWxCampFacilityByCfId(String cfId)
    {
        return campFacilityMapper.selectWxCampFacilityByCfId(cfId);
    }

    /**
     * 查询营地服务设施记录表列表
     *
     * @param campFacility 营地服务设施记录表
     * @return 营地服务设施记录表
     */
    @Override
    public List<WxCampFacility> selectWxCampFacilityList(WxCampFacility campFacility)
    {
        return campFacilityMapper.selectWxCampFacilityList(campFacility);
    }

    /**
     * 新增营地服务设施记录表
     *
     * @param campFacility 营地服务设施记录表
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = SecurityException.class)
    public int insertWxCampFacility(String campId,String[] facilityIds)
    {
//
//        for (String facilityId:facilityIds) {
//            CampFacility campFacility=new CampFacility();
//            campFacility.setCfId(IdUtils.randomUUID());
//            campFacility.setCampId(campId);
//            campFacility.setFacilityId(facilityId);
//            campFacilityMapper.insertWxCampFacility(campFacility);
//        }
        return 1;
//        return campFacilityMapper.insertCampFacility(campFacility);
    }

    /**
     * 修改营地服务设施记录表
     *
     * @param campFacility 营地服务设施记录表
     * @return 结果
     */
    @Override
    public int updateWxCampFacility(WxCampFacility campFacility)
    {
        return campFacilityMapper.updateWxCampFacility(campFacility);
    }

    /**
     * 批量删除营地服务设施记录表
     *
     * @param cfIds 需要删除的营地服务设施记录表主键
     * @return 结果
     */
    @Override
    public int deleteWxCampFacilityByCfIds(String[] cfIds)
    {
        return campFacilityMapper.deleteWxCampFacilityByCfIds(cfIds);
    }

    /**
     * 删除营地服务设施记录表信息
     *
     * @param cfId 营地服务设施记录表主键
     * @return 结果
     */
    @Override
    public int deleteWxCampFacilityByCfId(String cfId)
    {
        return campFacilityMapper.deleteWxCampFacilityByCfId(cfId);
    }
}
